<template>
    <view class="page">
       <u-navbar
           :fixed="true"
           placeholder
           :bgColor="themeColors"
           @leftClick="back"
         >
           <view class="navTitle" slot="left">
             <u-icon name="arrow-left" color="#FFF"></u-icon>
             <text style="margin-left: 20rpx">参观领票</text>
           </view>
       </u-navbar>
       <view>
         <image class="headerImg" :src="imgSrc" mode="scaleToFill" />
       </view>
       <view class="content" :style="'background-image:url('+bgImg+')'">
           <view class="btn" :style="'background:'+themeColors+';color:'+dcolor" @tap="toregister">领取门票</view>
       </view>
    </view>
   </template>
   
   <script>
   import {getLandingPage,getMyTicket} from "@/api/register";
   import {joinTeam} from "@/api/team";
   import {getInfo} from "@/api/list.js";
   export default {
    data() {
    return {
         themeColors: '',
         dcolor: '',
         imgSrc: '',
         bgImg:'',
    }
    },
    onLoad() {
      getInfo({exhibit_id:uni.getStorageSync('exhibit_id')}).then((res) => {
        this.imgSrc= res.data.img
        this.themeColors = res.data.color_main
        this.dcolor =  res.data.color_deputy
      })
      getLandingPage({enroll_team_id:uni.getStorageSync('team_id')}).then((res) => {
			    this.bgImg = res.data.img
		    })
        
    },
    methods: {
        toregister(){
            if(!uni.getStorageSync('token')){
                uni.navigateTo({ url: '/pages/login/index?data=pages_index/admission/share' })
            }else{
                uni.navigateTo({ url: '/pages_index/admission/index' })
                joinTeam({exhibit_id:uni.getStorageSync('exhibit_id'),enroll_team_id:uni.getStorageSync('team_id')}).then((res)=>{
                  getMyTicket({exhibit_id:uni.getStorageSync('exhibit_id')}).then((res)=>{
                    if (res.code == 1) {
                      this.lock = false;
                      uni.navigateTo({
                        url: '/pages/center/index'
                      })
                    }
                 
                  })
                })
            }
        },
        back(){
            uni.switchTab({ url: '/pages/index/index' })
        }
    },
   }
   </script>
   
   <style scoped lang="scss">
     .page {
     min-height: 92vh;
     background: rgb(239, 239, 239);
     padding-bottom: 0;
     padding-bottom: constant(safe-area-inset-bottom);
     padding-bottom: calc(50rpx + env(safe-area-inset-bottom));
     position: relative;
   }
   
     .navTitle {
       display: flex;
       color: rgb(255, 255, 255);
       font-size: 36rpx;
       font-weight: 700;
       line-height: 36rpx;
       text-align: left;
     }
     .headerImg {
       width: 750rpx;
       height: 532rpx;
     }
     .hint{
       width: 686rpx;
       height: 60rpx;
       margin: 0 auto;
       position: relative;
       top: -40rpx;
     }
     .content{
       position: relative;
       top: -40rpx;
       width: 660rpx;
       height: 668rpx;
       margin: 0 auto;
       background-size: contain;
       background-position: center;
       background-repeat: no-repeat;
       display: flex;
       justify-content: center;
       .btn{
        width: 440rpx;
        height: 72rpx;
        text-align: center;
        line-height: 72rpx;
        font-size: 36rpx;
        border-radius: 72rpx;
        position: absolute;
        bottom:90rpx;
       }
       
     }
   </style>
   